public class ThreadDemo13 {
    public static void main(String[] args) {
        Object object=new Object();
        Object object2=new Object();
        Thread thread1=new Thread(()->{
            System.out.println("A");
            synchronized(object){
                object.notify();
            }
        });
        Thread thread2=new Thread(()->{
            synchronized (object){
                try {
                    object.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("B");
               synchronized (object2) {
                   object2.notify();
               }
            }
        });
        Thread thread3=new Thread(()->{

            synchronized (object2){
                try {
                    object2.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("C");
            }
        });
        thread2.start();
        thread3.start();
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        thread1.start();

        try {
            thread1.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        try {
            thread2.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        try {
            thread3.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
